package com.advertisementsystem.Controller;


import com.advertisementsystem.Exception.ResponseResult;
import com.advertisementsystem.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/common")
@Slf4j
public class CommonController {
    @Autowired
    AliOssUtil aliOssUtil;
    @PostMapping("/upload")
    public ResponseResult upload(@RequestPart("file") MultipartFile file,
                                 @RequestParam("path") String path) throws IOException {
        path = "bishe";
        String[] s = aliOssUtil.upload(file,path);
        String url = s[0];
        return ResponseResult.success(url);
    }

}
